package com.rookie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.rookie.entity.Role;
import com.rookie.service.RoleService;
import com.rookie.mapper.RoleMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * service实现类
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {

    /**
     * 根据用户的id查询该用户的角色
     */
    @Override
    public List<Role> getRoleListByUId(Long id) {
        LambdaQueryWrapper<Role> wrapper = new LambdaQueryWrapper<>();
        wrapper.inSql(Role::getId, "SELECT role_id FROM sys_user_role WHERE user_id = " + id);
        return this.list(wrapper);
    }

}




